using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Atom.Data.ManagerObjects;
using Atom.Data.BusinessObjects;
using Atom.Data.Base;

namespace Atom.Data.UnitTests
{
	[TestFixture]
    public partial class HLeavehosRecordTests : UnitTestbase
    {
        [SetUp]
        public void SetUp()
        {
            manager = managerFactory.GetHLeavehosRecordManager();
            manager.Session.BeginTransaction();
        }

        [TearDown]
        public void TearDown()
        {
            manager.Session.RollbackTransaction();
            manager.Dispose();
        }
        
        protected Atom.Data.ManagerObjects.IHLeavehosRecordManager manager;
		
		protected Atom.Data.BusinessObjects.HLeavehosRecord CreateNewHLeavehosRecord()
		{
			Atom.Data.BusinessObjects.HLeavehosRecord entity = new Atom.Data.BusinessObjects.HLeavehosRecord();
			
			
			entity.Inhosid = "Tes";
			entity.Currentinhosmark = 29;
			entity.Diagnoseid = "Test Test Test Tes";
			entity.Caseid = "Tes";
			entity.Feetypeid = "Test ";
			entity.Sicktypeid = "Test ";
			entity.Enterhosofficeid = "Test Test Test Test";
			entity.Linkman = "T";
			entity.Relation = "Test Test Test ";
			entity.Inhosofficeid = "Test Te";
			entity.Address = "Test Test Test Test Test T";
			entity.Relationpostcode = "Te";
			entity.Enterhosdate = System.DateTime.Now;
			entity.Linkmode = "Test Test Test T";
			entity.Relationtelephone = "Test ";
			entity.Chargedoctorid = "Test Test Te";
			entity.Enterhosdiagnoseid = "Test T";
			entity.Entermode = "Tes";
			entity.Enterofficedate = System.DateTime.Now;
			entity.Officebedid = "Test Te";
			entity.Beddate = System.DateTime.Now;
			entity.Advancemoney = 13;
			entity.Inhostrack = "Test Test Test Tes";
			entity.Totalconsumemoney = 65;
			entity.Balancemoney = 23;
			entity.Clinicdoctorid = "Test";
			entity.Introducer = "Test Tes";
			entity.Afterabatemoeny = 1;
			entity.Cautionerid = "Test Test Test";
			entity.Inhospurposeid = "Test Te";
			entity.Inhostimes = 70;
			entity.Inhosstate = 73;
			entity.Motherid = "Test Test ";
			entity.Age = 69;
			entity.Ageunit = "Tes";
			entity.Enterhosoperatorid = "Test Te";
			entity.Leavehosdiagnoseid = "T";
			entity.Leavehosmode = "Test Test ";
			entity.Enterhostransactdate = System.DateTime.Now;
			entity.Leavehosdate = System.DateTime.Now;
			entity.Mark = "Test Test Test Test Test Te";
			entity.Inhosdays = 18;
			entity.Leavehosoperatorid = "Test";
			entity.Leavehostransactdate = System.DateTime.Now;
			entity.Tendlevel = "Test";
			
			return entity;
		}
		protected Atom.Data.BusinessObjects.HLeavehosRecord GetFirstHLeavehosRecord()
        {
            IList<Atom.Data.BusinessObjects.HLeavehosRecord> entityList = manager.GetAll(1);
            if (entityList.Count == 0)
                Assert.Fail("All tables must have at least one row for unit tests to succeed.");
            return entityList[0];
        }
		
		[Test]
        public void Create()
        {
            try
            {
				Atom.Data.BusinessObjects.HLeavehosRecord entity = CreateNewHLeavehosRecord();
				
                object result = manager.Save(entity);

                Assert.IsNotNull(result);
            }
            catch(Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        [Test]
        public void Read()
        {
            try
            {
                Atom.Data.BusinessObjects.HLeavehosRecord entityA = CreateNewHLeavehosRecord();
				manager.Save(entityA);

                Atom.Data.BusinessObjects.HLeavehosRecord entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA, entityB);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
		[Test]
		public void Update()
        {
            try
            {
                Atom.Data.BusinessObjects.HLeavehosRecord entityA = GetFirstHLeavehosRecord();
				
				entityA.Diagnoseid = "Test Test Test ";
				
				manager.Update(entityA);

                Atom.Data.BusinessObjects.HLeavehosRecord entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA.Inhosid, entityB.Inhosid);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        [Test]
        public void Delete()
        {
            try
            {
                Atom.Data.BusinessObjects.HLeavehosRecord entity = GetFirstHLeavehosRecord();
				
                manager.Delete(entity);

                entity = manager.GetById(entity.Id);
                Assert.IsNull(entity);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
	}
}

